<?php


namespace app\admin\controller\user;

use app\admin\model\UserChangeType;
use app\common\controller\AdminController;
use think\App;

/**
 * Class Changetype
 * @package app\admin\controller\user
 */
class ChangeType extends AdminController
{
    protected $relationSearch = true;//允许关联查询

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new UserChangeType;
    }

    /**
     *  获取变更类型，支持下拉列表
     * @author FashionJune
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            if (input('selectFields')) {
                return $this->selectList();
            }
            list($page, $limit, $where, $sort) = $this->buildTableParams();
            $count = $this->model
                ->where($where)
                ->count();
            $list = $this->model
                ->cache('change_type_list', 600)
                ->where($where)
                ->page($page, $limit)
                ->order($sort)
                ->select();
            $data = [
                'code' => 0,
                'msg' => '',
                'count' => $count,
                'data' => $list,
            ];
            return json($data);
        }
        return $this->fetch();
    }


}
